<template>
    <div>
        <div @click="er()">二维码</div>
        <div id="qrcode" ref="qrcode"></div>
    </div>
</template>
<script>
import QRCode from 'qrcodejs2'//转二维码
export default {
    data(){
        return{
           flag:true
        }
    },
    methods: { 
        er(){
            this.$nextTick(() => {
                this.qrcode()
            })
        },
        qrcode () {
            if(this.flag){
                this.flag=false
                let qrcode = new QRCode('qrcode',{
                    width: 200, // 设置宽度，单位像素
                    height: 200, // 设置高度，单位像素
                    text: 'https://www.baidu.com' // 设置二维码内容或跳转地址
                })
            }
        }
  }
}
</script>
<style scoped>

</style>